package ch11;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class _17_HashMapEx {
	public static void main(String[] args) {
		Map<String,String> map = new HashMap<String,String>();
		map.put("cat", "cat");
		map.put("dog", "1");
		map.put("dog", "dog");

		Scanner sc = new Scanner(System.in); 

		while (true) {
			System.out.print("id: ");
			String id = sc.nextLine().trim();
			System.out.print("password: ");
			String password = sc.nextLine().trim();

			if (!map.containsKey(id)) {
				System.out.println("This ID is not exist.");
				continue;
			} else {
				if (!(map.get(id)).equals(password)) 
					System.out.println("This PASSWORD is wrong.");
				else {
					System.out.println("Your ID & PASSWORD is right.");
					break;
				}
			}
		}
	} 
}
/*
id: hello
password: hello
This ID is not exist.
id: dog
password: 1
This PASSWORD is wrong.
id: dog
password: dog
Your ID & PASSWORD is right.
*/